<!DOCTYPE html>
<html>
	<head>
		<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
		<meta charset="utf-8">
		<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport">
		<meta content="yes" name="apple-mobile-web-app-capable">
		<meta content="black" name="apple-mobile-web-app-status-bar-style">
		<meta content="telephone=no" name="format-detection">
		<title>用户端</title>
		<link rel="stylesheet" href="__CDN__/qz/assets/frozenui-1.3.0/css/frozen.css">
		<link rel="stylesheet" type="text/css" href="__CDN__/qz/assets/css/style.css" />
	</head>

	<body class="body loginZ">
        <section class="login_block">
            <nav class="tap boxSD" id="navT">
                <a href="javascript:;" data-kind=1>登录</a>
                <a href="javascript:;" class="sure" data-kind=0>注册</a>
            </nav>
            <div>
                <ul class="zhuce_list">
                    <li>
                        <input type="number" name="mobile" placeholder="手机号" id='mobile'/>
                    </li>
                    <li>
                        <input type="number" name="code" placeholder="验证码" id='code'/>
                        <a href="javascript:;" class="floatR" id="sms">获取验证码</a>
                    </li>
                    <li>
                        <input type="hidden" name="communityid" value="{$communityid}">
                        <button type="button" class="nextBtn" id="next">下一步</button>
                    </li>
                </ul>
            </div>
        </section>
        <script type="text/javascript" src="__CDN__/qz/assets/js/jquery-1.11.3.min.js"></script>
        <script type="text/javascript" src="__CDN__/qz/assets/js/script.js"></script>
        <script type="text/javascript">
            function toJson(str){
             var json = (new Function("return " + str))();
             return json;
            }
            $("#sms").click(function(e){
                var data = {};
                data['mobile'] = $('#mobile').val();
                $.ajax({
                    type:'get',
                    url:'{:url("index/sms")}',
                    data:data,
                    success:function(result){
                        var obj = toJson(result);
                        alert(obj.msg);
                    }
                })
            });

            $(".nextBtn").on('click',function(){
                var id = $(this).attr('id');
                var url;
                var data = {};
                $('input').each(function(){
                    data[$(this).attr('name')] = $(this).val();
                })
                if(id == 'login'){
                    $.ajax({
                        type:'post',
                        url:'{:url("index/login")}',
                        data:data,
                        success:function(result){
                            var obj = toJson(result);
                            alert(obj.msg);
                        }
                    });
                }else{
                        $.ajax({
                        type:'post',
                        url:'{:url("index/verifyCode")}',
                        data:data,
                        success:function(result){
                            var obj = toJson(result);
                            alert(obj.msg);
                            if(obj.code == 0)
                            {
                                window.location.href = '{:url("index/register")}?communityid='+{$communityid}+"&mobile="+$('#mobile').val(); 
                            }
                        }
                    })
                }
            })
        </script>
	</body>
</html>